<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
		<title>更新首页</title>
		<link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
		<link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="/static/web/css/admin.css">
		<script src="/static/web/js/jquery.min.js"></script>
		<script src="/static/web/js/admin.main.js"></script>
	</head>
	<body>
		<form name="form1" action="makehtml_homepage.php" target="stafrm" method="post">
			<input type="hidden" name="dopost" value="make">
			<table class="table shadow-sm my-3">
				<tr>
					<td colspan="2">更新首页</td>
				</tr>
				<tr>
					<td width="260">选择首页模板：</td>
					<td>
						<input type="text" name="templet" id="templet" value="<?php echo $row['templet']?>" class="admin-input-sm">
						<button type="button" name="set4" class="btn btn-success btn-sm" onclick="SelectTemplets('form1.templet');">选择</button>
					</td>
				</tr>
				<tr>
					<td>首页位置：</td>
					<td><input type="text" name="position" id="position" value="<?php echo $row['position']?>" class="admin-input-sm"></td>
				</tr>
				<tr>
					<td>相关选项：</td>
					<td>
						<label><input type="radio" name="saveset" value="0"> 不保存当前选项</label>
						<label><input type="radio" name="saveset" value="1" checked> 保存当前选项</label>
					</td>
				</tr>
				<tr>
					<td>首页模式:</td>
					<td>
						<label><input type="radio" name="showmod" value="0" <?php echo ($row['showmod']==0)? "checked" : "";?>> 动态浏览</label>
						<label><input type="radio" name="showmod" value="1" <?php echo ($row['showmod']==1)? "checked" : "";?>> 生成静态</label>
					</td>
				</tr>
				<?php
				if (!empty($cfg_bizcore_appid) && !empty($cfg_bizcore_key)) {
					$client = new DedeBizClient();
					$data = $client->AdminPWDExists();
					if ($data->code == -1) {
				?>
				<tr>
					<td colspan="2">启动商业组件失败 <a href="https://www.dedebiz.com/start?code=-1008" target="_blank" class="btn btn-warning btn-sm">如何启动组件</a></td>
				</tr>
				<?php
				} else {
					$data = json_decode($data->data);
					$rs = (array)($data->result);
					if ($rs["admin_pwd_exists"] == "false") {
				?>
				<tr>
					<td>设置密码：</td>
					<td><input type="password" name="dedebiz_admin" autocomplete="off" id="dedebiz_admin" class="admin-input-sm">设定后所有的DedeBIZ涉及安全操作输入当前操作密码</td>
				</tr>
				<tr>
					<td>重复密码：</td>
					<td><input type="password" name="re_dedebiz_admin" autocomplete="off" id="re_dedebiz_admin" class="admin-input-sm"></td>
				</tr>
				<?php } else {?>
				<tr>
					<td>操作密码：</td>
					<td><input type="password" name="dedebiz_admin" autocomplete="off" id="dedebiz_admin" class="admin-input-sm"></td>
				</tr>
				<tr>
					<td>首页状态：</td>
					<td>
						<label><input type="radio" name="lockindex" value="unlock" <?php echo ($rs['index_lock_state']==true)? "checked" : "";?>> 解锁</label>
						<label><input type="radio" name="lockindex" value="lock" <?php echo ($row['index_lock_state']==false)? "checked" : "";?>> 锁定</label>
					</td>
				</tr>
				<?php }}} else {?>
				<tr>
					<td colspan="2">启动商业组件失败 <a href="https://www.dedebiz.com/start?code=-1008" target="_blank" class="btn btn-warning btn-sm">启动组件</a></td>
				</tr>
				<?php }?>
				<tr>
					<td colspan="2" align="center">
						<button type="submit" name="submit" class="btn btn-success btn-sm">开始更新</button>
						<button type="button" name="view" class="btn btn-outline-success btn-sm" onclick="window.open('makehtml_homepage.php?dopost=view&templet='+form1.templet.value);">预览首页</button>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<div id="mdv" class="admin-win-iframe"><iframe name="stafrm" frameborder="0" id="stafrm" width="100%" height="100%"></iframe></div>
					</td>
				</tr>
			</table>
		</form>
		<script>
			function SelectTemplets(fname) {
				var pos = GetWinPos(800, 600);
				window.open("./dialog/select_templets.php?f=" + fname, "poptempWin","scrollbars=yes,resizable=yes,statebar=no,width=800,height=600,left=" + pos.left + ", top=" + pos.top);
			}
			function htmlSubmit() {
				form1.submit();
				$("#dedebiz_admin").val("");
			}
		</script>
	</body>
</html>